import axios from 'axios';

const trajectoryRequest = axios.create({
  baseURL: "/trajectory",
  timeout: 3000,
  withCredentials: false
})

// 请求拦截器
trajectoryRequest.interceptors.request.use((config) => {
  return config;
}, (error: any) => {
  return Promise.reject(error);
})

// 响应拦截器
trajectoryRequest.interceptors.response.use(
  (response) => {
    if (response.status === 200) {
      return Promise.resolve(response);
    } else {
      return Promise.resolve(response);
    }
  },
  (error) => {
    if (error.message.includes('Network Error')) {
      console.error('跨域请求错误，请检查代理配置');
    }
    return Promise.reject(error);
  }
)

export default trajectoryRequest; 